home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / dwgExportOptions.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  13.1 KB  |  446 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. global proc int dwgExportOptions ( string $parent, string $action,  string $initialSettings,   string $resultCallback )
  18. //
  19. //    Description:
  20. //        This script posts the ODWG file translator options.
  21. //        The optionsString is of the form:
  22. //            varName1=value1;varName2=value2;...
  23. //
  24. //    Parameters:
  25. //        $parent - the elf parent layout for this options layout. It is
  26. //                    always a scrollLayout.
  27. //        $action - the action to be performed when this method is invoked.
  28. //                Valid options are:
  29. //                    "query" - construct the options string and 
  30. //                            pass it to the resultCallback.
  31. //                    "post" - post all the elf controls.
  32. //        $initialSettings - the current options string in effect at the
  33. //                           time this script is invoked.
  34. //        $resultCallback -
  35. //                This is the proc to be called with the result string. 
  36. //                resultCallback ( string $optionsString )
  37. //
  38. //    Returns:
  39. //        1 if successfull.
  40. //        0 otherwise.
  41. //
  42. {
  43.     int        $bResult;
  44.     string    $currentOptions;
  45.     string    $optionList[];
  46.     string    $optionBreakDown[];
  47.     int        $index;
  48.     
  49.     
  50.     
  51.  
  52.     if ($action == "post") {
  53.         setParent $parent;
  54.  
  55.         columnLayout -adj true -cal left odwgTypeCol;
  56.         text -label "";
  57.         // File Version Drop-Down Menu Box
  58.         
  59.         optionMenuGrp -label "Output file format" -cc updatedwgUnitsEnabled fileVersion;
  60.                 menuItem -label "ACAD25" ;
  61.                 menuItem -label "ACAD26" ;
  62.                 menuItem -label "ACAD9 " ;
  63.                 menuItem -label "ACAD10" ;
  64.                 menuItem -label "ACAD11" ;
  65.                 menuItem -label "ACAD13" ;
  66.                 menuItem -label "ACAD14" ;
  67.                 menuItem -label "ACAD2000" ;
  68.                 setParent ..;
  69.         //space
  70.         text -label "";
  71.         
  72.  
  73.  
  74.         optionMenuGrp -label "Units" -en false units;
  75.                 menuItem -label "Unitless";
  76.                 menuItem -label "Inches";
  77.                 menuItem -label "Feet";
  78.                 menuItem -label "Miles";
  79.                 menuItem -label "Millimeters";
  80.                 menuItem -label "Centimeters";
  81.                 menuItem -label "Meters";
  82.                 menuItem -label "Kilometers";
  83.                 menuItem -label "Microinches";
  84.                 menuItem -label "Miles";
  85.                 menuItem -label "Yards";
  86.                 menuItem -label "Angstroms";
  87.                 menuItem -label "Nanometers";
  88.                 menuItem -label "Microns";
  89.                 menuItem -label "Decimeters";
  90.                 menuItem -label "Decameters";
  91.                 menuItem -label "Hectometers";
  92.                 menuItem -label "Gigameters";
  93.                 menuItem -label "Astronomical units";
  94.                 menuItem -label "Light years";
  95.                 menuItem -label "Parsecs";
  96.                 
  97.  
  98.         //space
  99.         text -label "";
  100.  
  101.  
  102.         rowLayout -numberOfColumns 2;
  103.             text -label "Scale factor";
  104.             floatField -minValue 0 -maxValue 10000 -precision 4 -value 1 scaleField;
  105.         setParent ..;
  106.  
  107.         //space
  108.         text -label "";
  109.  
  110.         //____________________________________________________________________________________
  111.         
  112.         text -label "Polygon Mesh Options" -fn "boldLabelFont" -w 200 -al "left";
  113.         
  114.         text -label "";
  115.  
  116.         rowLayout -numberOfColumns 2;    
  117.             text -label "Tessellation";
  118.             columnLayout;
  119.                 radioCollection odwgExportCollection;
  120.                     radioButton -label "No tessellation"     -align "right" noTessellate;
  121.                     radioButton -label "Triangulate"     -align "right" triangulate;
  122.                     radioButton -label "Quadrangulate"     -align "right" quadrangulate;
  123.             setParent ..;
  124.         setParent ..;
  125.         
  126.         //space
  127.         text -label "";
  128.  
  129.         
  130.  
  131.         rowLayout -numberOfColumns 2;
  132.                 
  133.             text -label "Export as";
  134.             columnLayout;
  135.                 radioCollection odwgExportPolygonFormat;
  136.                 radioButton -label "Polyface Mesh"     -align "left" polyface;
  137.                 radioButton -label "Separate Polyfaces"    -align "left" sepPolyface;
  138.                 radioButton -label "3D Faces"         -align "left" face;
  139.             setParent ..;
  140.         setParent ..;
  141.  
  142.         //space
  143.         text -label "";
  144.  
  145.         
  146.  
  147.  
  148.         // set defaults
  149.         //_______________________________________________________________________________________
  150.         
  151.             
  152.         
  153.         
  154.         // N U R B S
  155.  
  156.         text -label "NURBS Surface Tessellation Options" -w 300 -fn "boldLabelFont" -al "left";
  157.         text -label "";
  158.  
  159.         rowLayout -numberOfColumns 2 ;    
  160.         
  161.             text -label "Type" ;
  162.     
  163.             columnLayout;
  164.                 radioCollection odwgNurbSurfTesselation;
  165.                     radioButton -label "Triangulate"     -align "right" nurbTriangulate;
  166.                     radioButton -label "Quadrangulate"     -align "right" nurbQuadrangulate;
  167.                 setParent ..;
  168.             setParent ..;
  169.  
  170.         //space
  171.         text -label "";
  172.         
  173.                 
  174.         rowLayout -numberOfColumns 2 ;
  175.         
  176.             text -label "Method" -align "left";
  177.  
  178.             columnLayout;
  179.                 radioCollection tessMethod;
  180.                     radioButton -label "General"         -align "left" -cc ("nurbsToPolyVis " + $parent + " 0")    general ;
  181.                     radioButton -label "Standard Fit"     -align "left" -cc ("nurbsToPolyVis " + $parent + " 1")     standard ;
  182.                     radioButton -label "Count"         -align "left" -cc ("nurbsToPolyVis " + $parent + " 2")    count;
  183.             setParent ..;            
  184.         setParent ..;
  185.  
  186.         //space
  187.         text -label "";
  188.         
  189.         //____________________________________________________________________________________
  190.  
  191.  
  192.         tabLayout -tabsVisible false formatTabs;
  193.  
  194.         columnLayout tabGeneral;
  195.             
  196.             text -l " Initial Tessellation Controls" -align "left";
  197.  
  198.             // U-Type
  199.             optionMenuGrp -l "U Type" uType;
  200.                         menuItem -l "Per Surf # of Iso Params in 3D";
  201.                         menuItem -l "Per Surf # of Iso Params";
  202.                         menuItem -l "Per Span # of Iso Params";
  203.  
  204.             intSliderGrp -label "Number U"     -min 1 -max 32 -fmx 10000 -f true uNumber;
  205.  
  206.                
  207.             //space
  208.             text -label "";
  209.         
  210.  
  211.  
  212.             // V-Type
  213.     
  214.             optionMenuGrp -l "V Type" vType;
  215.                         menuItem -l "Per Surf # of Iso Params in 3D";
  216.                         menuItem -l "Per Surf # of Iso Params";
  217.                         menuItem -l "Per Span # of Iso Params";
  218.  
  219.             intSliderGrp -label "Number V"     -min 1 -max 32 -fmx 10000  -f true vNumber;
  220.  
  221.         setParent ..;
  222.  
  223.  
  224.         //_______________________________________________________________________________
  225.  
  226.         columnLayout tabStandard;            
  227.             floatSliderGrp -l "Chord Height Ratio"    -min 0.01     -max 0.2 -f true -pre 3 -s 0.01 ratioS;
  228.             floatSliderGrp -l "Fractional Tolerance"-min 0.001    -max 1.0 -fmn 0.000001 -fmx 1.0 -f true -pre 4 -s 0.001 fractional;
  229.             floatSliderGrp -l "Minimal Edge Length" -min 0.0001 -max 1.0  -f true -pre 4 -s 0.001 minEdgeLength;
  230.             floatSliderGrp -l "3D Delta"         -min 0.01     -max 1.0  -fmn 0.001 -fmx 1.0  -f true -pre 4 -s 0.001 delta;
  231.         setParent ..;
  232.  
  233.         //____________________________________________________________________________________
  234.  
  235.         columnLayout tabCount;
  236.             intSliderGrp -label "Count" -f true -min 1 -max 1000 -fmx 1000000 gCount;
  237.         setParent ..;
  238.  
  239.         //____________________________________________________________________________________
  240.  
  241.         columnLayout tabNothing;
  242.         setParent ..;
  243.         setParent ..;
  244.  
  245.         
  246.         columnLayout;
  247.             text -label "";
  248.             text -label "";
  249.             button -l "Restore Defaults" -al "center" -c restoreDefaultOptions  -w 150 -h 30 restoreDefaultsButton;
  250.         setParent ..;
  251.         
  252.         restoreDefaultOptions;
  253.  
  254.         //______________________________________________________________________________________
  255.         
  256.  
  257.         // Now set to current settings.
  258.  
  259.         $currentOptions = $initialSettings;
  260.  
  261.  
  262.  
  263.         if (size($currentOptions) > 0) {
  264.             tokenize($currentOptions, ";", $optionList);
  265.             
  266.             for ($index = 0; $index < size($optionList); $index++) {
  267.                 tokenize($optionList[$index], "=", $optionBreakDown);
  268.  
  269.                 if ($optionBreakDown[0] == "tessellate") {
  270.                     if ($optionBreakDown[1] == "0") {
  271.                         radioButton -e -sl noTessellate;
  272.                     } else if ($optionBreakDown[1] == "1") {
  273.                         radioButton -e -sl triangulate;
  274.                     } else if ($optionBreakDown[1] == "2") {
  275.                         radioButton -e -sl quadrangulate;
  276.                     }
  277.                 } else if ($optionBreakDown[0] == "fileVersion") { 
  278.                     // these 2 line are causing trouble.
  279.                     int $fileVersionInt = $optionBreakDown[1];
  280.                     optionMenuGrp -e -sl $fileVersionInt fileVersion;
  281.                 } else if ($optionBreakDown[0] == "scale") {
  282.                     float $scaleFloat = $optionBreakDown[1];
  283.                     floatField -e -value $scaleFloat scaleField;
  284.                 } else if ($optionBreakDown[0] == "units") {
  285.                     int $unitsInt = $optionBreakDown[1];
  286.                     optionMenuGrp -e -sl $unitsInt units;
  287.                 } else if ($optionBreakDown[0] == "polyFormat") {
  288.                     if ($optionBreakDown[1] == "0") {
  289.                         radioButton -e -sl polyface;
  290.                     }else if ($optionBreakDown[1] == "1") {
  291.                         radioButton -e -sl sepPolyface;
  292.                     }else if ($optionBreakDown[1] == "2") {
  293.                         radioButton -e -sl face;
  294.                     }
  295.                 }
  296.             }
  297.         }
  298.         $result = 1;
  299.  
  300.         
  301.  
  302.     } else if ($action == "query") {
  303.         
  304.         if (`radioButton -q -sl noTessellate` == 1) {
  305.             $currentOptions = $currentOptions + "tessellate=0";
  306.         } else if (`radioButton -q -sl triangulate` == 1) {
  307.             $currentOptions = $currentOptions + "tessellate=1";
  308.         } else {
  309.             $currentOptions = $currentOptions + "tessellate=2";
  310.         }
  311.  
  312.         
  313.         $fileVersionInt = `optionMenuGrp -q -sl fileVersion`;
  314.         $currentOptions = $currentOptions + ";fileVersion=" + $fileVersionInt;
  315.  
  316.         
  317.         $currentOptions = $currentOptions + ";scale="         + (`floatField -q -v scaleField`);
  318.  
  319.         int $unitsInt = `optionMenuGrp -q -sl units`;
  320.         $currentOptions = $currentOptions + ";units=" + $unitsInt;
  321.  
  322.         if (`radioButton -q -sl polyface` == 1) {
  323.             $currentOptions = $currentOptions + ";polyFormat=0";
  324.         } else if (`radioButton -q -sl sepPolyface` == 1) {
  325.             $currentOptions = $currentOptions + ";polyFormat=1";
  326.         } else if (`radioButton -q -sl face` == 1) {
  327.             $currentOptions = $currentOptions + ";polyFormat=2";
  328.         }
  329.         
  330.  
  331.         //____________________________ nurbs Surface Tessellation
  332.         
  333.         if (`radioButton -q -sl nurbTriangulate` == 1) {
  334.             $currentOptions = $currentOptions + ";nurbSurfTess=0";
  335.         } else if (`radioButton -q -sl nurbQuadrangulate` == 1) {
  336.             $currentOptions = $currentOptions + ";nurbSurfTess=1";
  337.         } 
  338.  
  339.  
  340.         if (`radioButton -q -sl standard` == 1) {
  341.             $currentOptions = $currentOptions + ";nurbSurfTessType=standardFit";
  342.         } else if (`radioButton -q -sl general` == 1) {
  343.             $currentOptions = $currentOptions + ";nurbSurfTessType=general";
  344.         } else if (`radioButton -q -sl count` == 1) {
  345.             $currentOptions = $currentOptions + ";nurbSurfTessType=count";
  346.         } 
  347.         
  348.  
  349.         //standard-fit data
  350.         $currentOptions = $currentOptions + ";chordHtRatio="     + (`floatSliderGrp -q -v ratioS`);
  351.         $currentOptions = $currentOptions + ";fracTolerance="     + (`floatSliderGrp -q -v fractional`);
  352.         $currentOptions = $currentOptions + ";midEdgeLength="     + (`floatSliderGrp -q -v minEdgeLength`);
  353.         $currentOptions = $currentOptions + ";delta="         + (`floatSliderGrp -q -v delta`);
  354.  
  355.         //general-data
  356.         $currentOptions = $currentOptions + ";count="     + (`intSliderGrp -q -v gCount`);
  357.  
  358.         //count data
  359.         $currentOptions = $currentOptions + ";uType="     + (`optionMenuGrp -q -v uType`);
  360.         $currentOptions = $currentOptions + ";uNumber=" + (`intSliderGrp  -q -v uNumber`);        
  361.         $currentOptions = $currentOptions + ";vType="     + (`optionMenuGrp -q -v vType`);
  362.         $currentOptions = $currentOptions + ";vNumber=" + (`intSliderGrp  -q -v vNumber`);
  363.  
  364.  
  365.  
  366.         eval($resultCallback+" \""+$currentOptions+"\"");
  367.         $result = 1;
  368.     } else {
  369.         $bResult = 0;
  370.     }
  371.     
  372.     return $bResult;
  373. }
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380. global proc nurbsToPolyVis( string $parent, int $format )
  381. {
  382.     setParent $parent;
  383.     switch( $format ) {
  384.       case 0:
  385.       default:
  386.         tabLayout -e -selectTab tabGeneral formatTabs;
  387.         break;
  388.       case 1:
  389.         tabLayout -e -selectTab tabStandard formatTabs;
  390.         break;
  391.       case 2:
  392.         tabLayout -e -selectTab tabCount formatTabs;
  393.         break;
  394.       case 3:
  395.         tabLayout -e -selectTab tabNothing formatTabs;
  396.         break;
  397.     }
  398.     
  399.  
  400. }
  401.  
  402.  
  403. global proc restoreDefaultOptions ()
  404. {
  405.     optionMenuGrp -e -v "ACAD2000" fileVersion;
  406.  
  407.     optionMenuGrp -e -en true units;
  408.     optionMenuGrp -e -v "Centimeters" units;
  409.  
  410.     floatField -e -v 1.00 scaleField;
  411.     radioCollection -e -sl noTessellate odwgExportCollection;
  412.     radioCollection -e -sl polyface odwgExportPolygonFormat;
  413.     
  414.     radioCollection -e -sl nurbQuadrangulate odwgNurbSurfTesselation;
  415.     
  416.     radioCollection -e -sl standard tessMethod;
  417.     
  418.     floatSliderGrp -e -v 0.1 ratioS;
  419.     floatSliderGrp -e -v 0.01 fractional;
  420.     floatSliderGrp -e -v 0.001 minEdgeLength;
  421.     floatSliderGrp -e -v 0.1 delta;
  422.  
  423.  
  424.     optionMenuGrp -e -v "Per Surf # of Iso Params in 3D" uType;
  425.     optionMenuGrp -e -v "Per Surf # of Iso Params in 3D" vType;    
  426.     intSliderGrp  -e -v 3         uNumber;
  427.     intSliderGrp  -e -v 3         vNumber;
  428.     
  429.     intSliderGrp -e -v 200 gCount;
  430.         
  431. }
  432.  
  433.  
  434. global proc updatedwgUnitsEnabled()
  435. {
  436.     if (`optionMenuGrp -q -v fileVersion` == "ACAD2000")
  437.     {    
  438.         optionMenuGrp -e -en true units;
  439.     }
  440.     else
  441.     {
  442.         optionMenuGrp -e -en false units;
  443.     }
  444. }
  445.  
  446.